package opearaion;

import book.Book;
import book.BookList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2021-12-09
 * Time: 12:13
 */
public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        System.out.println("借阅图书");
        System.out.println("请输入你要借阅图书的名字");
        String name = scanner.nextLine();
        int size = booklist.getSize();
        for (int i = 0; i < size; i++) {
            Book book = booklist.getPos(i);
            if (name.equals(book.getName())) {
                book.setBorrowed(true);
                System.out.println("借阅成功");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到你要借阅的图书");
    }
}
